extends ../layouts/default

block content
  - var action = '/articles'
  if (!article.isNew)
    - action += '/'+article.id

  if (typeof errors !== 'undefined')
    .fade.in.alert.alert-block.alert-error
      a.close(data-dismiss="alert", href="javascript:void(0)") x
      ul
        each error in errors
          li= error.type

  .row
    .span7
      form.form-horizontal(method="post", action=action, enctype="multipart/form-data")
        if (!article.isNew)
          input(type="hidden", name="_method", value="PUT")

        .control-group
          label.control-label(for='title') Title
          .controls
            input#title.input-xlarge(type='text', name="title", value=article.title, placeholder='Enter the title')

        .control-group
          label.control-label(for='title') Image
          .controls
            input(type='file', name="image[]")

        .control-group
          label.control-label(for='desc') Body
          .controls
            textarea#desc.input-xlarge(type='text', rows="5", name="body", placeholder='Enter the article description')=article.body

        .control-group
          label.control-label(for='desc') Tags
          .controls
            input#tags(type='text', name="tags", value=article.tags, placeholder='Enter the tags')

        .form-actions
          button.btn.btn-primary(type='submit') Save changes
          &nbsp;
          a.btn(href='/articles', title="cancel") Cancel
    .span5
      if (!article.isNew && article.image && article.image.files && article.image.files.length)
        img(src=article.image.cdnUri + '/mini_' + article.image.files[0])
